package com.kkb.dao;

import com.kkb.pojo.Account;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface AccountDao {
    // 新增账户
    @Insert("insert into tb_account values (#{id}, #{name}, #{money})")
    void addAccount(Account newAccount);

    // 根据id删除账户
    @Delete("delete from tb_account where id = #{id}")
    void deleteAccountById(Integer id);

    // 更新账户
    @Update("update tb_account set name=#{name},money=#{money} where id=#{id}")
    void updateAccount(Account account);

    // 根据id查询账户
    @Select("select * from tb_account where id = #{id}")
    Account findAccountById(Integer id);

    // 根据name模糊查询所有账户
    @Select("select * from tb_account where name like concat('%',#{partname},'%')")
    List<Account> findAccountsByName(String partname);

    // 查询所有账户
    @Select("select * from tb_account")
    List<Account> findAccounts();
}
